/**
 * Created by liumengjun on 2017-07-20.
 */
def fib
//fib = { long n -> n < 2 ? n : fib(n - 1) + fib(n - 2) }
//assert fib(31) == 1346269 // slow!

fib = { long n -> n < 2 ? n : fib(n - 1) + fib(n - 2) }.memoize()
assert fib(31) == 1346269 // fast!
